<?php

namespace App\Repositories\SeminarTemplates;

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Models\SeminarTemplates\Seminar;
use App\Validators\SeminarValidator;

/**
 * Class SeminarRepositoryEloquent.
 *
 * @package namespace App\Repositories;
 */
class SeminarRepositoryEloquent extends BaseRepository implements SeminarRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return Seminar::class;
    }

    

    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }

    /**
     * 获取指定id专题信息
     * @author Jerry
     * @param int $id
     * @param int $isShow
     * @return mixed
     */
    public function findSeminarById(int $id, int $isShow)
    {
        $time = time();

        $where = [
            'id'        =>  $id,
            ['start_time', '<=', $time],
            ['end_time', '>', $time],
        ];

        if ($isShow) {
            $where = [
                'id'    =>  $id,
            ];
        }

        return $this->findWhere($where)->first();
    }
    
}
